<?php

/*
 *Form to edit the profile of the user
 * @author Dominik Imsirovic
 * 
 */
class Application_Form_Update extends Zend_Form {
    public function __construct($options = null) {
        parent::__construct($options);

        // Set the method for the display form to POST
        $this->setMethod('post');

        $session = Zend_Registry::get("my_session_namespace");
        
//Add text field to enter user name
        $this->addElement('text', 'name', array(
            'label' => 'Your real name:',
            'required' => true , 
            'value' =>$session->user["name"],
            'filters' => array('StringTrim'),
                 'validators' => array(
                new Zend_Validate_StringLength(array(
                    'min' => 1,
                    'max' => 30 )),new Zend_Validate_Alnum())));
        
        //Add text field to enter location
        $this->addElement('text', 'location', array(
            'label' => 'Your location:',
            'required' => false,
             'value' => $session->user["location"],
            'filters' => array('StringTrim'),
             'validators' => array(
                new Zend_Validate_StringLength(array(
                    'min' => 1,
                    'max' => 30 )),new Zend_Validate_Alnum())));
        
        
        //Add text field to enter birthdate
        $this->addElement('text', 'birthdate', array(
            'label' => 'Your birthdate:',
            'required' => false,
            'value' => $session->user["birthdate"],
           'validators'=>array(new Zend_Validate_Date())));
        
        //Add text field to enter a description of the user
        $this->addElement('textarea', 'description', array(
            'label' => 'A description of yourself:',
            'required' => false,
             'rows' => 5,
            'cols' => 50,
             'value' => $session->user["description"] ,
             'validators' => array(
                new Zend_Validate_StringLength(array(
                    'min' => 1,
                    'max' => 200 )))));
        
        
        //Add file element to upload a profile picture
        $this->addElement('file', 'picture', array('label' => 'Your profile picture:', 
            'destination' => APPLICATION_PATH.'/../public/images/upload/'));
        

         // Add the submit button
       $this->addElement('submit', 'update', array(
            'ignore' => true,
            'label' => 'Update Profile',
        ));
    }
}
?>
